SITL: add basic support for visual odometry simulation #12414
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With many new developments for visual odometry (VO), it would be very helpful to have SITL support so that we can replicate and investigate issues that happen in various scenarios. This PR attempts to provide a simulated VO system onboard the vehicle.
The normal operation of the simulated VO system is:
param set SIM_VISO_ENABLE 1
. VO system always starts at(0, 0, 0)
and have a heading of0
. Upon enabling the simulated VO will start sendingVISION_POSITION_ESTIMATE
message to the vehicle.param set SIM_VISO_ENABLE 0
, which would stop sending the message immediately. When the system is enabled again, the original position and heading are reset.In this first PR, 3 of the most frequent kinds of issues encountered with VO is simulated:
-- Usage: scale can be modified with
SIM_VISO_SCALE
. For example,param set SIM_VISO_SCALE 0.9
will make moving 1m in any axis into 0.9m in reported position in the message.-- Usage: first define divergence rate, e.g.
param set SIM_VISO_DIVRATE 1.01
is 1% increase of position in each step. Start the divergence withparam set SIM_VISO_ERROR 1
.-- Usage: start the jump with
param set SIM_VISO_ERROR 1
. Set the param to 0 then 1 to jump again.This is by no means a thorough simulation of VO, but I hope this can be a stepping stone for upcoming developments in the codebase.
Some observations:
SIM_Vicon
, which also utilizes theVISION_POSITION_ESTIMATE
message, some of the most noticable differences are:Thus, I believe there would be more room for future developments by separating the two types instead of building on top of the existing
SIM_Vicon
.In my SITL tests, most of the times when divergence occurs the copter would keep moving a bit before
EKF Variance
error appears, subsequently it would switch toland
.Jumping of 1m when the vehicle is moving does not seem to have any effect, but when the vehicle is stationary in some cases I encounter
EKF variance error
.With
COMPASS_USE
enable, the heading will start at some direction of compass, then slowly moves to 0, similar to what I observe with real copter. In my tests, I usually disable all compass withparam set COMPASS_USE 0
as well asCOMPASS_USE2
andCOMPASS_USE3
.